<?php

/**
 * SfGuardUser filter form.
 *
 * @package    virtualdelivery
 * @subpackage filter
 * @author     Your name here
 */
class SfGuardUserFormFilter extends BaseSfGuardUserFormFilter {

    public function configure() {
        parent::configure();

        unset(
            $this['password'],
            $this['salt'],
            $this['algorithm'],
            $this['is_super_admin']
        );
    }

    public function setup() {
        parent::setup();
        
        $this->setWidgets(array(
            'username' => new sfWidgetFormFilterInput(array('with_empty' => false)),
            'algorithm' => new sfWidgetFormFilterInput(),
            'salt' => new sfWidgetFormFilterInput(),
            'password' => new sfWidgetFormFilterInput(array('with_empty' => false)),
            'created_at' => new sfWidgetFormFilterDate(array('from_date' => new mtWidgetFormInputDateFilter(), 'to_date' => new mtWidgetFormInputDateFilter(), 'with_empty' => false, 'template' => 'desde %from_date% <br/>hasta %to_date%')),
            'last_login' => new sfWidgetFormFilterDate(array('from_date' => new mtWidgetFormInputDateFilter(), 'to_date' => new mtWidgetFormInputDateFilter(), 'with_empty' => false, 'template' => 'desde %from_date% <br/>hasta %to_date%')),
            'is_active' => new sfWidgetFormInputCheckbox(),
            'is_super_admin' => new sfWidgetFormFilterInput(array('with_empty' => false)),
            'sf_guard_user_group_list' => new sfWidgetFormPropelChoice(array('model' => 'SfGuardGroup', 'add_empty' => 'Seleccione una opcion')),
            'sf_guard_user_permission_list' => new sfWidgetFormPropelChoice(array('model' => 'SfGuardPermission', 'add_empty' => 'Seleccione una opcion')),
        ));

        $this->setValidators(array(
            'username' => new sfValidatorSchemaFilter('text', new sfValidatorString(array('required' => false))),
            'algorithm' => new sfValidatorPass(array('required' => false)),
            'salt' => new sfValidatorPass(array('required' => false)),
            'password' => new sfValidatorPass(array('required' => false)),
            'created_at' => new sfValidatorDateRange(array('required' => false, 'from_date' => new mtValidatorDateString(array('required' => false)), 'to_date' => new mtValidatorDateString(array('required' => false)))),
            'last_login' => new sfValidatorDateRange(array('required' => false, 'from_date' => new mtValidatorDateString(array('required' => false)), 'to_date' => new mtValidatorDateString(array('required' => false)))),
            'is_active' => new sfValidatorBoolean(),
            'is_super_admin' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
            'sf_guard_user_group_list' => new sfValidatorPropelChoice(array('model' => 'SfGuardGroup', 'required' => false)),
            'sf_guard_user_permission_list' => new sfValidatorPropelChoice(array('model' => 'SfGuardPermission', 'required' => false)),
        ));

        $this->widgetSchema->setLabels(array(
            'username' => 'Usuario',
            'created_at' => 'Creado',
            'last_login' => 'Ultimo ingreso',
            'is_active' => 'Activo',
            'sf_guard_user_group_list' => 'Grupos',
            'sf_guard_user_permission_list' => 'Permisos',
        ));

        $this->widgetSchema->setNameFormat('sf_guard_user_filters[%s]');

        $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

}

}
